<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>答卷</title>
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/js/easyui/themes/default/easyui.css" />
	<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/js/easyui/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/js/easyui/locale/easyui-lang-zh_CN.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/js/page/questionnaire/questionnaireAnswer.js"></script>
</head>
<body>
<input type="hidden" id="questionnaireId" value="${questionnaireId }">
<input type="hidden" id="questionnaireAnswerId" value="${answerId }">
<input type="hidden" id="txtQuestionnaireId" value="${questionnaireId }">

<div id="divOptions" style="padding-left: 5%;">
	<div style="border: 1px solid #CCDDFF;padding: 10px;width: 80%;">
		提交人：<span id="spAnswerUser">&nbsp;</span><br/>
		提交时间：<span id="spAnswerDate">&nbsp;</span>
	</div>
<c:forEach var="question" items="${ questions}" varStatus="status">
<div style="margin-top: 10px;">
    <div>
    <b>${ status.index + 1}  ${question.description }    </b>
    </div>
	<div style="padding-left: 6px;" name="question_${question.id }" title="${question.id }" type="${question.type }">
		<c:forEach var="option" items="${ question.questionOptions}" varStatus="status">
			<div>
			<span id="sp_option_${question.id }_${option.id }">&nbsp;&nbsp;</span>
			<c:out value="${option.description }"/>
			</div>
		</c:forEach>
		<c:if test="${question.type==3 }">
			<span id="sp_txt_${question.id }">&nsbp;</span>
		</c:if>
	</div>
</div>
</c:forEach>

<div id="div_answerFiles" style="margin-top: 10px;">

</div>

<div id="div_diagnosis_content" style="display: none;margin-top: 10px;border: 1px solid #CCDDFF;padding: 10px;width: 80%;">
	诊断结果：<span id="td_diagnosis">&nbsp;</span><br/>
	诊断医生：<span id="td_doctorName">&nbsp;</span><br/>
	诊断时间：<span id="td_diagnosis_date">&nbsp;</span>
</div>
<c:if test="${goback==true}">
<div id="div_diagnosis" style="display: none;margin-top: 10px;padding: 10px;width: 80%;border: 1px solid #CCDDFF;">
	<strong>诊断结果：</strong>
	<form id="frmQuestionnaireDiagnosis">
	<div style="width: 400px;">
		 &nbsp;
		 <input type="hidden" id="id" name="id" value="${answerId }">
		 G<input id="txtZdg" name="zdg" class="easyui-numberspinner" data-options="min:0,max:9,required:true" style="width: 50px;">
		 P<input id="txtZdp" name="zdp" class="easyui-numberspinner" data-options="min:0,max:9,required:true" style="width: 50px;">
		 <input id="txtZdz" name="zdz" class="easyui-numberspinner" data-options="min:5,max:20,required:true" style="width: 50px;">+
		 <input id="txtZdt" name="zdt" class="easyui-numberspinner" data-options="min:0,max:6,required:true" style="width: 50px;">周
		 <br/>
		 <input id="txtZdHandle_rglc" type="radio" name="zdHandle" value="人工流产"><label for="txtZdHandle_rglc">人工流产</label>
		 <input id="txtZdHandle_ywlc" type="radio" name="zdHandle" value="药物流产/清宫"><label for="txtZdHandle_ywlc">药物流产/清宫</label>
		 <input id="txtZdHandle_ywrs" type="radio" name="zdHandle" value="异位妊娠"><label for="txtZdHandle_ywrs">异位妊娠</label>
		 <input id="txtZdHandle_zy" type="radio" name="zdHandle" value="早孕"><label for="txtZdHandle_zy">早孕</label>
		 <br/>
		 <input id="txtZdHandle_other" type="radio" name="zdHandle" value="" >
		 <label for="txtZdHandle_other">
		 <input id="txtZdHandle_other_content" type="text" class="easyui-textbox" name="zdHandle_other" style="width: 280px;" data-options="prompt:'其他'">
		 </label>
	</div>
	</form>
</div>
</c:if>

<c:if test="${goback==true}">
	<div style="text-align: center;">
		<a href="/pac/questionnaire/gotoPage?pageName=questionnaireAnswerList&questionnaireType=${questionnaireType }">返回</a>
		<div id="div_btn_diagnosis" style="display: none;margin-left: 30px;">
			<a href="javascript:void(0)" onclick="submitDiagnosis()">提交诊断</a>
		</div>
	</div>
</c:if>
</div>
<script type="text/javascript">
$(function(){

	var questionnaireId=$("#txtQuestionnaireId").val();
	var questionnaireAnswerId=$("#questionnaireAnswerId").val();
	
	$("div[name^='question_']").each(function(obj){
		var questionId=$(this).attr("title");//问题ID
		var questionType=$(this).attr("type");//题型，1：单选，2：多选，3：问答
		$.ajax({
			type: "post",
			url: "/pac/questionnaire/question/answer/get",
			data:{
				questionnaireId:questionnaireId,
				questionId:questionId,
				answerId:questionnaireAnswerId
			},
			success: function(data){
				var answers=data.answer;
				if(data.result==true&&null!=answers&&answers.length>0)
				{
					if(questionType=='3')
					{
						var answerObj=answers[0];
						$("#sp_txt_"+questionId).html(answerObj.answer);
					}
					else
					{
						for(var n=0;n<answers.length;n++)
						{
							var answerObj=answers[n];
							$("#sp_option_"+questionId+"_"+answerObj.optionId).html("√");
						}
					}
				}
			}
		});
	});
	
});

//获取诊断结果
function querDiagnosis()
{
	var questionnaireAnswerId=$("#questionnaireAnswerId").val();
	$.ajax({
		type: "post",
		url: "/pac/questionnaire/diagnosis/get",
		data:{
			diagnosisId:questionnaireAnswerId
		},
		success: function(data){
			$("#spAnswerUser").html(data.patientName);
			$("#spAnswerDate").html(data.answerDate);
			if(""!=data.diagnosisDate&&null!=data.diagnosisDate)
			{
				$("#div_diagnosis_content").show();
				$("#td_diagnosis").html(data.diagnosis);
				$("#td_doctorName").html(data.doctorName);
				$("#td_diagnosis_date").html(data.diagnosisDate);
			}
			else
			{
				$("#div_diagnosis").show();
				$("#div_btn_diagnosis").css("display","inline");
				$("#div_btn_edit_answer").css("display","inline");
			}
		}
	});
}
</script>
</body>
</html>